/**
 * 两种方式获取Provider
 * 1.通过Provider.of()获取
 * 2.通过Consumer获取
 */
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../provider/counter_provider.dart';

class ProviderDemoSecondPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("ProviderDemoPage"),
      ),
      body: Consumer2<CounterProvider, int>(
          builder: (context, CounterProvider provider, testSize, _) {
        return Center(
          child: Text(
            "Value:${provider.value}",
            style: TextStyle(fontSize: testSize.toDouble()),
          ),
        );
      }),
      floatingActionButton: Consumer<CounterProvider>(
        builder: (context, CounterProvider provider, child) =>
            FloatingActionButton(
              child: child,
              onPressed: () => provider.increment(),
            ),
        child: Icon(Icons.add),
      ),
    );
  }
}
